asm
  ld sp,$CFFF
  end asm

#include "./library/pacmandelay.bas"
'#include "./library/pbactionputsprite.bas"
#include "./library/smsrnd.bas"

dim i as uinteger at $C010
dim eee as uinteger at $C012
dim seed as uinteger at $C014

dim ee1 as uinteger at $C022
dim ee2 as uinteger at $C016
dim ee3 as uinteger at $C018
dim ee4 as ubyte at $C01A
dim ecsp as ubyte at $C01C
dim ecsq as ubyte at $C01E

dim ej0 as uinteger at $C020

dim ex2 as uinteger at $C028
dim ey2 as uinteger at $C02A
dim ex3 as uinteger at $C02C
dim ey3 as uinteger at $C02E
dim ex0 as uinteger at $C030
dim ey0 as uinteger at $C032
dim ex1 as uinteger at $C034
dim ey1 as uinteger at $C036
dim ex6 as uinteger at $C038
dim ey6 as uinteger at $C03A
dim ex7 as uinteger at $C03C
dim ey7 as uinteger at $C03E
dim ex4 as uinteger at $C040
dim ey4 as uinteger at $C042
dim ex5 as uinteger at $C044
dim ey5 as uinteger at $C046

dim zzz as uinteger at $C048


sub pbactionputsprite(tlayer as ubyte,tx as ubyte,ty as ubyte,tid as ubyte,tclut as ubyte):
  poke $E000+((tlayer band 31)*4),tid          '- shape sprite 0
  poke $E001+((tlayer band 31)*4),tclut        '- clut? sprite 0
  'poke $E002+((tlayer band 31)*4),tx  bxor $ff '- x sprite 0
  'poke $E003+((tlayer band 31)*4),ty bxor $ff  '- y sprite 0
  poke $E002+((tlayer band 31)*4),tx   '- x sprite 0
  poke $E003+((tlayer band 31)*4),ty   '- y sprite 0
  end sub

sub pbactionpalette(tid1 as uinteger,tvl1 as uinteger):
  '$E400:gr ; $E401:xb
  poke $E400+(tid1*2),((tvl1 band $0F00)/256) bor (tvl1 band $F0)
  poke $E401+(tid1*2),tvl1 band $FF
  end sub

sub pbactionpalettepeekuinteger(tid1 as uinteger,tvl1 as uinteger):
  '$E400:gr ; $E401:xb
  poke $E401+(tid1*2),((tvl1 band $0F00)/256) bor (tvl1 band $F0)
  poke $E400+(tid1*2),tvl1 band $FF
  end sub

sub pbactionputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte, tla1 as uinteger)
  poke ($D000+(tla1*$800)+(txp1*32)+typ1) bxor %0000001111100000,tch1
  poke ($D400+(tla1*$800)+(txp1*32)+typ1) bxor %0000001111100000,tat1
  end sub

seed=0
for eee=$0000 to 255
  pbactionpalettepeekuinteger(eee,peek (uinteger,@palettetest01z1+(eee*2)) )
  next

for eee=1 to 10:  seed=smsrnd(seed):next


for eee=$0000 to 255
  seed=smsrnd(seed)
  pbactionpalettepeekuinteger(eee,seed)
  next

pbactionpalette(1,$A96)
pbactionpalette(128,$156)

'pbactionpalette(1,$F55)
'pbactionpalette(2,$5F5)
'pbactionpalette(3,$55F)

'-------------------------------------------------------------------------------

'function test1(t1 as uinteger,t2 as uinteger,t3 as uinteger,t4 as uinteger)  as uinteger
'  end function

sub zpoke(t1 as uinteger,t2 as ubyte)
  poke t1,t2
  end sub

sub putchar(tx1 as uinteger, ty1 as uinteger, tch1 as uinteger)
  poke ($D000+(tx1*32)+ty1) bxor %0000001111100000,(tch1 band 255)
  end sub

pbactionputsprite(0,21,10,4,3)
pbactionputsprite(1,21,30,4,3)
pbactionputsprite(2,21,50,4,3)
pbactionputsprite(3,21,70,4,3)
pbactionputsprite(4,21,90,4,3)
pbactionputsprite(5,21,110,4,3)
pbactionputsprite(6,21,130,4,3)
pbactionputsprite(7,21,150,4,3)

seed=0

for ee3=0 to 31
  for ee2=0 to 31
    seed=smsrnd(seed)
    pbactionputchar(ee2,ee3,seed band $07,(seed band $F0)/16,1)
    next:next

'- hello world
for ee2=0 to 11
  pbactionputchar(ee2+13,13,peek(@text01+ee2),0,0)
  pbactionputchar(ee2+13,13,0,0,1)
  next

'- ascii
for ee3=0 to 15
  for ee2=0 to 15
    pbactionputchar(ee2+13,ee3+15,ee3*16+ee2,0,0)
    pbactionputchar(ee2+13,ee3+15,0,0,1)
    next:next

'eee=$4207
'i=code("Q")
'poke eee,i
'eee=eee+1
'i=code("T")
'poke eee,i

''????????
'seed=0
'for eee=$4400 to $47FF
'  seed=smsrnd(seed)
'  poke eee,seed
'  next

ex0=20:ey0=10:ex1=20:ey1=30
ex2=20:ey2=50:ex3=20:ey3=70
ex4=20:ey4=90:ex5=20:ey5=110
ex6=20:ey6=130:ex7=20:ey7=150
eee=0:ecsp=0:ecsq=0

do
poke $50C0,255 '- watchdog? - it seems to work! thanks, Jim Bagley!!!!

'poke ($D000+(6*32)+20) bxor %0000001111100000,ej0
'poke ($D000+(7*32)+20) bxor %0000001111100000,ej1

pbactionputchar(8,22,48+(ex0 mod 10),0,0)
pbactionputchar(7,22,48+((int(ex0/10)) mod 10),0,0)
pbactionputchar(6,22,48+((int(ex0/100)) mod 10),0,0)

pbactionputchar(8,23,48+(ey0 mod 10),0,0)
pbactionputchar(7,23,48+((int(ey0/10)) mod 10),0,0)
pbactionputchar(6,23,48+((int(ey0/100)) mod 10),0,0)

pbactionputchar(8,24,48+(eee mod 10),0,0)
pbactionputchar(7,24,48+((int(eee/10)) mod 10),0,0)
pbactionputchar(6,24,48+((int(eee/100)) mod 10),0,0)
pbactionputchar(5,24,48+((int(eee/1000)) mod 10),0,0)
pbactionputchar(4,24,48+((int(eee/10000)) mod 10),0,0)

ej0=peek($E600) bxor $00
pbactionputchar(8,25,48+(ej0 mod 10),0,0)
pbactionputchar(7,25,48+((int(ej0/10)) mod 10),0,0)
pbactionputchar(6,25,48+((int(ej0/100)) mod 10),0,0)

if ecsp=0 then:
  ex0=ex0+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey0=ey0+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=1 then:
  ex1=ex1+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey1=ey1+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=2 then:
  ex2=ex2+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey2=ey2+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=3 then:
  ex3=ex3+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey3=ey3+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=4 then:
  ex4=ex4+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey4=ey4+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=5 then:
  ex5=ex5+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey5=ey5+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=6 then:
  ex6=ex6+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey6=ey6+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if
if ecsp=7 then:
  ex7=ex7+((ej0 band 4)/4)-((ej0 band 1)/1)
  ey7=ey7+((ej0 band 16)/16)-((ej0 band 8)/8)
  end if

ej0=peek($E601) bxor $00
pbactionputchar(8,26,48+(ej0 mod 10),0,0)
pbactionputchar(7,26,48+((int(ej0/10)) mod 10),0,0)
pbactionputchar(6,26,48+((int(ej0/100)) mod 10),0,0)

if (ej0 band 15)<>0 then: ecsq=ecsq+1:end if
ecsp=(int(ecsq/4))mod 8

ej0=peek($E602) bxor $00
pbactionputchar(8,27,48+(ej0 mod 10),0,0)
pbactionputchar(7,27,48+((int(ej0/10)) mod 10),0,0)
pbactionputchar(6,27,48+((int(ej0/100)) mod 10),0,0)

ej0=peek($E603) bxor $00
pbactionputchar(8,28,48+(ej0 mod 10),0,0)
pbactionputchar(7,28,48+((int(ej0/10)) mod 10),0,0)
pbactionputchar(6,28,48+((int(ej0/100)) mod 10),0,0)

poke ($D000+(8*32)+29) bxor %0000001111100000,48+(ecsp mod 10)

pbactionputchar(12,8,eee,eee,0)
pbactionputchar(12,8,eee,eee,1)

ee3=int(eee/4)

pbactionputsprite(0,ex0,ey0,4,3)  '- layer,x,y,id,clut
pbactionputsprite(1,ex1,ey1,ee3,3)  '- layer,x,y,id,clut
pbactionputsprite(2,ex2,ey2,4,ee3)  '- layer,x,y,id,clut
pbactionputsprite(3,ex3,ey3,ee3,ee3)  '- layer,x,y,id,clut
pbactionputsprite(4,ex4,ey4,4,3)  '- layer,x,y,id,clut
pbactionputsprite(5,ex5,ey5,ee3,3)  '- layer,x,y,id,clut
pbactionputsprite(6,ex6,ey6,4,ee3)  '- layer,x,y,id,clut
pbactionputsprite(7,ex7,ey7,ee3,ee3)  '- layer,x,y,id,clut

for zzz=0 to 1000:next

eee=eee+1
loop

do:loop

'-------------------------------------------------------------------------------

text01:
asm
  defb "HELLO WORLD!!!!!"
  end asm

'-------------------------------------------------------------------------------

goto palettetest01z1end:
palettetest01z1:
asm

  defw $000,$00A,$A00,$A0A,$0A0,$0AA,$AA0,$AAA
  defw $000,$00F,$F00,$F0F,$0F0,$0FF,$FF0,$FFF

  defw $000,$010,$020,$030,$040,$050,$060,$070 ;g
  defw $080,$090,$0A0,$0B0,$0C0,$0D0,$0E0,$0F0
  defw $000,$100,$200,$300,$400,$500,$600,$700 ;b
  defw $800,$900,$A00,$B00,$C00,$D00,$E00,$F00
  defw $FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF ;r
  defw $EDC,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
  defw $FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF ;r
  defw $008,$009,$00A,$00B,$00C,$00D,$00E,$00F
  defw $000,$010,$020,$030,$040,$050,$060,$070 ;g
  defw $080,$090,$0A0,$0B0,$0C0,$0D0,$0E0,$0F0
  defw $000,$100,$200,$300,$400,$500,$600,$700 ;b
  defw $800,$900,$A00,$B00,$C00,$D00,$E00,$F00
  defw $000,$111,$222,$333,$444,$555,$666,$777 ;bgr
  defw $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF

  defw $48C,$00A,$A00,$A0A,$0A0,$0AA,$AA0,$AAA
  defw $000,$00F,$F00,$F0F,$0F0,$0FF,$FF0,$FFF

  defw $000,$010,$020,$030,$040,$050,$060,$070 ;g
  defw $080,$090,$0A0,$0B0,$0C0,$0D0,$0E0,$0F0
  defw $000,$100,$200,$300,$400,$500,$600,$700 ;b
  defw $800,$900,$A00,$B00,$C00,$D00,$E00,$F00
  defw $000,$111,$222,$333,$444,$555,$666,$777 ;bgr
  defw $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
  defw $FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF ;r
  defw $DCE,$009,$00A,$00B,$00C,$00D,$00E,$00F
  defw $000,$010,$020,$030,$040,$050,$060,$070 ;g
  defw $080,$090,$0A0,$0B0,$0C0,$0D0,$0E0,$0F0
  defw $000,$100,$200,$300,$400,$500,$600,$700 ;b
  defw $800,$900,$A00,$B00,$C00,$D00,$E00,$F00
  defw $000,$111,$222,$333,$444,$555,$666,$777 ;bgr
  defw $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF

  end asm

palettetest01z1end:

'-------------------------------------------------------------------------------

